<template>
	<div class="newsinfo-container">
		<h3 class="title">{{newsinfo.title}}</h3>
		<p class="subtitle">
			<span>{{newsinfo.add_time | dataFormt}}</span>
			<span>点击:{{newsinfo.click}}次</span>
		</p>
		<hr>
		<div class="content" v-html="newsinfo.content">
			
		</div>
		<!-- 评论子组件 -->
		<comment-box></comment-box>
	</div>
</template>

<script>
	import {Toast} from 'mint-ui'
	import comment from '../subcomponents/comment.vue'
	export default {
		data(){
			return {
				id:this.$route.params.id ,//将url的id值传递过来 保存到data上
				newsinfo:{}
			}
		},
		created(){
			this.getNewsinfo()
		},
		methods:{
			getNewsinfo(){
				this.axios.get('/home/newinfo'+'?id='+this.id)
				  .then(result =>{
					  if(result.data.err_code === 0){
						  this.newsinfo = result.data.getitem
					  }else{
						  Toast('获取新闻失败')
					  }
				  })
			}
		},
		components:{
			//注册评论子组件
			"comment-box":comment
		}
	}
</script>

<style lang="scss" scoped>
	.newsinfo-container{
		padding:0 4px; 
		.title{
			font-size: 16px;
			text-align:center;
			margin: 15px 0;
			color: #000;
		}
		.subtitle{
			font-size: 13px;
			color: aqua;
			display: flex;
			justify-content: space-around;
		}
		.content{
			img{
				width: 100%;
			}
		}
	}
</style>
